//
//  NSString+DM_Base64.m
//  24-加密
//
//  Created by dllo on 16/8/16.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "NSString+DM_Base64.h"

@implementation NSString (DM_Base64)
- (NSString *)stringWithBase64 {
    // NSString 转换 data
    NSData *stringData = [self dataUsingEncoding:NSUTF8StringEncoding];
    // NSData 进行Base64, 生成字符串
    NSString *baseString = [stringData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    
    return baseString;
}
- (NSData *)base64StringWithData {
    // 根据Base64字符串, 生成NSData
    return [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
}

- (NSString *)base64WithString {
    // 把Base64转成字符串
    NSString *orginString = [[NSString alloc]initWithData:[self base64StringWithData] encoding:NSUTF8StringEncoding];
    return orginString;
}
@end
